/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package coalescent.nb.jobs1;

import cef.command.Command;
import cef.pui.EventConstructionException;
import coalescent.cef.command.RunRecursionCommand;
import coalescent.cef.command.listener.RunRecursionCommandListener;
import coalescent.cef.pui.RunRecursionEventImpl;
import coalescent.cef.pui.pob.Builders_Coa;
import coalescent.nb.jobs.properties.ComboPropertys_Coa;
import commons.nb.jobs.Job;

import java.util.Properties;

import static coalescent.nb.jobs.properties.ComboPropertys_Coa.Recursion_Computations;

/**
 * @author Susanta Tewari
 * @since Jun 4, 2011
 */
public class KC64RunRecursionJob extends Job<RunRecursionEventImpl> {

    public KC64RunRecursionJob() {

        setName("Infinite-Alleles Model");
        setDisplayName("Infinite-Alleles (KC64)");
        setDisplayName("Infinite-Alleles (KC64)");


        // model
        addComboProperty(ComboPropertys_Coa.K69("coalescent.builder.PopGenModel"));


        // data
        addComboProperty(ComboPropertys_Coa.An("coalescent.builder.AC"));
        addComboProperty(Recursion_Computations("coalescent.builder.RecursionComputations"));


        // listeners
        addCommandOutputListener(new RunRecursionCommandListener());
    }

    @Override
    public Properties getProperties() {

        final Properties props = super.getProperties();

        props.setProperty("coalescent.builder.PopGenModel.delegate",
                          Builders_Coa.Model_KC64.class.getName());
        props.setProperty("coalescent.builder.AC.delegate", Builders_Coa.AC_KC64.class.getName());

        return props;
    }

    @Override
    public boolean isCancellable() {
        return RunRecursionCommand.isCancellable();
    }

    @Override
    protected RunRecursionEventImpl createEvent() throws EventConstructionException {
        return new RunRecursionEventImpl.DEFAULT(getProperties());
    }

    @Override
    public Class<RunRecursionEventImpl> getEventImplType() {
        return RunRecursionEventImpl.class;
    }

    @Override
    protected Command createCommand(final RunRecursionEventImpl event) {
        return new RunRecursionCommand(event);
    }
}
